package com.qf.agro.controller;

import com.qf.agro.common.ResultInfo;
import com.qf.agro.pojo.Facilities;
import com.qf.agro.pojo.FacilitiesCategory;
import com.qf.agro.service.FacilitiesCategoryService;
import com.qf.agro.service.FacilitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 10202
 * @version V1.0
 * @Project smart-agriculture-parent
 * @Package com.qf.agro.controller
 * @Date 2023/7/3 17:49
 */
@RestController
public class FacilitiesController {

    @Autowired
    private FacilitiesService facilitiesService;

    @GetMapping("facilities/facilities/page")
    public ResultInfo getpage(@RequestParam(value = "page",defaultValue = "1") Long page,@RequestParam Long pageSize,String name){


        return facilitiesService.getPage(page,pageSize,name);
    }

    @PostMapping("facilities/facilities")
    public ResultInfo insertMessage(@RequestBody Facilities facilities)
    {

        return facilitiesService.save(facilities);
    }

    @DeleteMapping("facilities/facilities")
    public ResultInfo DeleteCategory(Long id){

        return facilitiesService.deleteById(id);
    }

    @PutMapping("facilities/facilities")
    public ResultInfo updateCategory(@RequestBody Facilities facilities){
        return facilitiesService.update(facilities);
    }

    @GetMapping("facilities/facilities/selectOptions")
    public ResultInfo getOptions()
    {

        return facilitiesService.getOptions();
    }

    @GetMapping("facilities/category/options")
    public ResultInfo getOptions1()
    {

        return facilitiesService.getOptions();
    }



}
